<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.base.myproject.server.tools.*" %>
<%@ page import="com.base.myproject.client.jdbc.DataSet,java.util.Date" %>
<%@page import="java.text.SimpleDateFormat,java.util.Calendar,java.math.BigDecimal"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>

<title></title>
<%
	String excel = request.getParameter("excel");
	if (excel != null && !excel.equals("")) {
		response.setHeader("Content-disposition","attachment; filename=SearchContract.xls");
		//response.setCharacterEncoding("UTF-8");
	}
	String number = request.getParameter("number");
	String style = request.getParameter("style");
	String name2 = request.getParameter("name2");
	String contract2 = request.getParameter("contract2");
	String searchBeginDate = request.getParameter("searchBeginDate");
	String searchEndDate = request.getParameter("searchEndDate");
	String contract_begin = request.getParameter("contract_begin");
	String contract_end = request.getParameter("contract_end");
	
	DataSetTool DST = new DataSetTool();
	
	String sql = "select employinnertitle,hr_bcode_contract.contract_begin_date,hr_bcode_contract.contract_end_date,v_bcode2job.employno,v_bcode2job.bname,bcode.bird,up_department,bcode.departments,bcode.hr_firstname_en,bcode_job.entrydate from hr_bcode_contract,bcode,v_bcode2job,bcode_job where v_bcode2job.bcode = bcode.bcode and bcode.bcode = hr_bcode_contract.bcode and bcode.bcode = bcode_job.bcode and exists (select 1 from bcode_job where employstatus = '在职' and bcode = hr_bcode_contract.bcode)and convert(varchar(10),contract_begin_date,120)< convert(varchar(10),contract_end_date,120) ";
	if (!number.equals("0")) {
		sql += " and hr_bcode_contract.bcode = '" + number + "'";
	}
	
	if (!style.equals("0")) {
		
		sql += " and  contract_type in (select name from  dictionary where code = '"+ style + "')";
	}
	if (!name2.equals("0")) {
		sql += " and departments ='" + name2 + "'";
	}
	if (!contract2.equals("0")) {
		sql += " and contract_name like '%" + contract2 + "%'";
	}
	if (!searchBeginDate.equals("0")) {
		sql += " and contract_begin_date >= '" + searchBeginDate + "'";
	}
	if (!searchEndDate.equals("0")) {
		sql += " and contract_begin_date <= '" + searchEndDate + "'";
	}
	if (!contract_begin.equals("0")) {
		sql += " and contract_end_date >=  '" + contract_begin + "'";
	}
	if (!contract_end.equals("0")) {
		sql += " and contract_end_date <= '" + contract_end + "'";
	}
	

	DataSet result = DST.getDataSet(sql);
%>
</head>

<body>

	<table style="border-collapse: collapse" border="1" align="center"  cellspacing="0" cellpadding="3" border="1" width="100%" bordercolordark="#CCCCCC" bordercolorlight="#CCCCCC" style="border-color:#000000;">
		<tr bgcolor="#e8e8e0" align="center" >
			<td>姓名</td>
			<td>雇佣编号</td>
			<td>部门</td>
			<td>英文名</td>
			<td>出生日期</td>
			<td>职位</td>
			<td>入职日期</td>
		    <td>合同开始日</td>
		    <td>合同到期日</td>
		    <td>签收</td>
		</tr>
		<%
			for(int i = 0;i < result.getRowCount();i++){
				
		%>
				<tr>
					<td><%= result.getValue(i,"bname") %></td>
					<td><%=result.getValue(i,"employno") %></td>
					<td><%=result.getValue(i,"departments") %></td>
					
					<td><%=result.getValue(i,"hr_firstname_en") %></td>
					<td><%=result.getValue(i,"bird") %></td>
					<td ><%=result.getValue(i,"employinnertitle") %></td>
					<td ><%=result.getValue(i,"entrydate") %></td>
					<td><%=result.getValue(i,"contract_begin_date") %></td>
					<td><%=result.getValue(i,"contract_end_date") %></td>
					
					<td></td>
			</tr>
		<%		
			}
		%>
	</table>
</body>

</html>